<?php
/**
 * Created By PhpStorm
 * Author: patrick wu
 * Date: 2021/1/16
 * Time: 14:20
 */
namespace App\Http\Controllers\Api;

use App\Constant\ErrorConstant;
use Illuminate\Http\Request;
use App\Service\Api\LimitService;

class LimitController extends BaseController
{
    protected $service;

    public function __construct(Request $request, LimitService $service)
    {
        parent::__construct($request);

        $this->service  =   $service;
    }

    /**
     * 限时折扣商品
     * @return \Illuminate\Http\JsonResponse
     */
    public function limitGoods()
    {
        $page   =   (int) $this->request->input('page', 1);
        [$flag, $result]    =   $this->service->listLimit($page);
        if ($flag) {
            return $this->successResponse($result);
        } else {
            return $this->errorResponse(ErrorConstant::API_LIMIT_GOODS_LIST, $result);
        }
    }
}
